package com.example.second_home_work

import android.os.Bundle
import android.widget.Button
import android.widget.LinearLayout
import android.widget.Spinner
import android.widget.TextView
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import org.w3c.dom.Text

class MainActivity : AppCompatActivity() {
    var count=0
    val expert=ProgramExpert()
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_main)
        val button2 = findViewById<Button>(R.id.button2)
        val spinner=findViewById<Spinner>(R.id.spinner)
        val textView=findViewById<TextView>(R.id.textView)
        button2.setOnClickListener{

            textView.text=expert.getLanguage((spinner.selectedItem.toString()))
        }
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom)
            insets
        }
        val button =findViewById<Button>(R.id.button)
        val linearLayout =findViewById<LinearLayout>(R.id.linearLayout)
        button.setOnClickListener{
            val textView = TextView(this)
            count++
            textView.text="New TextView $count !"
            linearLayout.addView(textView)
        }
    }
}